import numpy as np

class Matrix(object):
    def __init__(self, m, n, need_grad):
        self.m = m
        self.n = n
        self.data = np.random.normal(0.0, pow(n, -0.5), (m, n))
        self.need_grad = need_grad

    def __mul__(self, x):
        y = np.dot(self.data, x)

        def back_propa(outputs):
            d_e = outputs
            d_self = x.T
            d_x = self.data.T
            if self.need_grad:
                self.data -= np.data(d_e, d_self)

            return [d_self, d_x]
            
        

m1 = matrix(784, 200)
m2 = matrix(200, 10)

def fc1(x):
    y = m1 * x

    def back_propagate(outputs):
        d_e = outputs
        d_m1 
        if m1.need_grad:
            m1 = m1 - d_e * x.transpose()
        return [x.transpose(), m1.transpose()]

    return y
